Notions of Bidirectional Computation and Entangled State Monads
نویسندگان
چکیده
Bidirectional transformations (bx) support principled consistency maintenance between data sources. Each data source corresponds to one perspective on a composite system, manifested by operations to ‘get’ and ‘set’ a view of the whole from that particular perspective. Bx are important in a wide range of settings, including databases, interactive applications, and model-driven development. We show that bx are naturally modelled in terms of mutable state; in particular, the ‘set’ operations are stateful functions. This leads naturally to considering bx that exploit other computational effects too, such as I/O, nondeterminism, and failure, all largely ignored in the bx literature to date. We present a semantic foundation for symmetric bidirectional transformations with effects. We build on the mature theory of monadic encapsulation of effects in functional programming, develop the equational theory and important combinators for effectful bx, and provide a prototype implementation in Haskell along with several illustrative examples.
منابع مشابه
Entangled State Monads
We present a monadic treatment of symmetric state-based bidirectional transformations, and show how it arises naturally from the well-known asymmetric lens-based account. We introduce two presentations of a concept we dub the “entangled” state monad, and prove their equivalence. As a step towards a unifying account of bidirectionality in general, we exhibit existing classes of statebased approa...
متن کاملNotions of Computation Determine Monads
We model notions of computation using algebraic operations and equations. We show that these generate several of the monads of primary interest that have been used to model computational effects, with the striking omission of the continuations monad. We focus on semantics for global and local state, showing that taking operations and equations as primitive yields a mathematical relationship tha...
متن کاملNotions of Computation as Monoids
There are different notions of computation, the most popular being monads, applicative functors, and arrows. In this article we show that these three notions can be seen as monoids in a monoidal category. We demonstrate that at this level of abstraction one can obtain useful results which can be instantiated to the different notions of computation. In particular, we show how free constructions ...
متن کاملIdioms are Oblivious, Arrows are Meticulous, Monads are Promiscuous
We revisit the connection between three notions of computation: Moggi’s monads, Hughes’s arrows and McBride and Paterson’s idioms (also called applicative functors). We show that idioms are equivalent to arrows that satisfy the type isomorphism A;B ' 1 ; (A→ B) and that monads are equivalent to arrows that satisfy the type isomorphism A; B ' A → (1 ; B). Further, idioms embed into arrows and ar...
متن کاملModular Modelling with Monads
One useful application of category theory in computer science are computational monads, which are used to model diverse computational effects (such as stateful computations, exceptional behaviour or non-determinism). This goes back to Moggi [6], and is for example used to great effect in the pure functional language Haskell [8, 11]. In this talk, we use the same technique to model computational...
متن کامل